import os,sys,time
sys.path.append("../")
from am import AndroidAm
from logcat import logcat
import subprocess
dev_id = sys.argv[1]
print dev_id
am=AndroidAm()
logcat=logcat()		
am.ConnectWifi(dev_id,"5g5g","null")
am.startEndpoint(dev_id)
print '##################################'
cmd = []
cmd.append('adb')
cmd.append('-s')
cmd.append(dev_id)
cmd.append('shell')
cmd.append('netcfg')
fdp = subprocess.Popen( cmd, stdout = subprocess.PIPE )
			
for line in fdp.stdout:
    if line.find("wlan0")!=-1:
        print dev_id+":"+line.split()[2].strip()

